home *** CD-ROM | disk | FTP | other *** search
/ Master Visual Basic 3 / Master Visual Basic 3 (SAMS Publishing) (1994).ISO / mvprog / original / ch13 / whatami.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-03-16  |  4.0 KB  |  128 lines

  1. VERSION 2.00
  2. Begin Form frmWhatAmI 
  3.    Caption         =   "The WhatAmI Program"
  4.    ClientHeight    =   5355
  5.    ClientLeft      =   975
  6.    ClientTop       =   690
  7.    ClientWidth     =   7770
  8.    Height          =   5760
  9.    Icon            =   WHATAMI.FRX:0000
  10.    Left            =   915
  11.    LinkTopic       =   "Form1"
  12.    Picture         =   WHATAMI.FRX:0302
  13.    ScaleHeight     =   5355
  14.    ScaleWidth      =   7770
  15.    Top             =   345
  16.    Width           =   7890
  17.    Begin CommandButton cmdExit 
  18.       Caption         =   "E&xit"
  19.       Height          =   495
  20.       Left            =   3360
  21.       TabIndex        =   2
  22.       Top             =   4680
  23.       Width           =   1215
  24.    End
  25.    Begin CommandButton cmdWhoAmI 
  26.       Caption         =   "What Am I?"
  27.       FontBold        =   -1  'True
  28.       FontItalic      =   0   'False
  29.       FontName        =   "MS Sans Serif"
  30.       FontSize        =   12
  31.       FontStrikethru  =   0   'False
  32.       FontUnderline   =   0   'False
  33.       Height          =   495
  34.       Left            =   3120
  35.       TabIndex        =   1
  36.       Top             =   120
  37.       Width           =   2055
  38.    End
  39.    Begin Label Label1 
  40.       Alignment       =   2  'Center
  41.       BackColor       =   &H00C0C0C0&
  42.       BorderStyle     =   1  'Fixed Single
  43.       FontBold        =   -1  'True
  44.       FontItalic      =   0   'False
  45.       FontName        =   "MS Sans Serif"
  46.       FontSize        =   12
  47.       FontStrikethru  =   0   'False
  48.       FontUnderline   =   0   'False
  49.       ForeColor       =   &H00000000&
  50.       Height          =   495
  51.       Left            =   2520
  52.       TabIndex        =   0
  53.       Top             =   720
  54.       Width           =   3375
  55.    End
  56. Option Explicit
  57. ' Declare constants
  58. Const WF_CPU286 = &H2
  59. Const WF_CPU386 = &H4
  60. Const WF_CPU486 = &H8
  61. ' Declare the GetWinFlags() DLL function
  62. Declare Function GetWinFlags Lib "Kernel" () As Long
  63. ' Declare a variable the will hold the session number.
  64. Dim gSessionNumber
  65. ' Declare constants
  66. Const SP_START_OF_FILE = -1
  67. Const SP_END_OF_FILE = -2
  68. ' Declare the sp_OpenSession() function from
  69. ' the TegoSND.DLL library.
  70. Declare Function sp_OpenSession Lib "TegoSND.DLL" (ByVal lpstrFileName As String) As Integer
  71. ' Declare the sp_PlaySnd() function from
  72. ' the TegoSND.DLL library.
  73. Declare Function sp_PlaySnd Lib "TegoSND.DLL" (ByVal iSessionHandler As Integer, ByVal lStartPoint As Long, ByVal lEndPoint As Long) As Long
  74. ' Declare the sp_CloseSession() function from
  75. ' the TegoSND.DLL library.
  76. Declare Function sp_CloseSession Lib "TegoSND.DLL" (ByVal iSessionHandler As Integer) As Integer
  77. Sub cmdExit_Click ()
  78.     Dim Dummy
  79.     Dummy = sp_CloseSession(gSessionNumber)
  80.     ' Terminate the application
  81.     End
  82. End Sub
  83. Sub cmdWhoAmI_Click ()
  84.     Dim ThisIsWhatIAm
  85.     Dim Dummy
  86.     ThisIsWhatIAm = GetWinFlags()
  87.     ' Play I am...
  88.     Dummy = sp_PlaySnd(gSessionNumber, SP_START_OF_FILE, 16200)
  89.     If ThisIsWhatIAm And WF_CPU286 Then
  90.        
  91.       Label1.Caption = "I Am a 80286"
  92.       frmWhatAmI.Refresh
  93.       
  94.       ' Play the WAV file through the PC speaker
  95.       Dummy = sp_PlaySnd(gSessionNumber, 17600, 42200)
  96.       
  97.       Exit Sub
  98.     End If
  99.     If ThisIsWhatIAm And WF_CPU386 Then
  100.        
  101.       Label1.Caption = "I Am a 80386"
  102.       frmWhatAmI.Refresh
  103.       ' Play the WAV file through the PC speaker
  104.       Dummy = sp_PlaySnd(gSessionNumber, 58290, 87150)
  105.       
  106.       Exit Sub
  107.     End If
  108.     If ThisIsWhatIAm And WF_CPU486 Then
  109.       
  110.       Label1.Caption = "I Am a 80486"
  111.       frmWhatAmI.Refresh
  112.       
  113.       ' Play the WAV file through the PC speaker
  114.       Dummy = sp_PlaySnd(gSessionNumber, 98970, 131000)
  115.       
  116.       Exit Sub
  117.     End If
  118.            
  119.     Label1.Caption = "I don't know who am I..."
  120. End Sub
  121. Sub Form_Load ()
  122.     ' Open a WAV session
  123.     gSessionNumber = sp_OpenSession("C:\MVPROG\WAV\WHATAMI.WAV")
  124. End Sub
  125. Sub Form_Unload (Cancel As Integer)
  126.     cmdExit_Click
  127. End Sub
  128.